package net.wexoo.onlinedivelog.entity.person;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import net.wexoo.onlinedivelog.entity.diveLevel.DiveLevelBean;

/**
 * @author wexoo
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(of = "id")
@Entity
@Table(name = "PERSON")
@Inheritance(strategy = InheritanceType.JOINED)
public class PersonBean implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
	@SequenceGenerator(name = "generator", sequenceName = "PERSON_SEQUENCE")
	@Column(name = "ID")
	private Integer id;

	@Column(name = "EMAIL")
	private String email;

	@Column(name = "FORENAME")
	private String forename;

	@Column(name = "LOGIN")
	private String login;

	@Column(name = "PASSWORD")
	private String password;

	@Column(name = "SURNAME")
	private String surname;

	@ManyToOne
	@JoinColumn(name = "DIVE_LEVEL")
	private DiveLevelBean diveLevel;

	public PersonBean(DiveLevelBean diveLevel, String login, String password,
			String forename, String surname, String email) {
		this.diveLevel = diveLevel;
		this.login = login;
		this.password = password;
		this.forename = forename;
		this.surname = surname;
		this.email = email;
	}
}